<?php

namespace api\business\controller;

use cmf\controller\RestAdminBaseController;

class CateController extends RestAdminBaseController
{
    function lists()
    {
        $arrData['parent_id'] = $this->request->param('id', 0, 'intval');
        $arrData['is_del'] = 0;
        $lists = db('industry_cate')->field('id,name')->where($arrData)->select();
        $this->success('success',$lists);
    }

    /**
     * 复选
     * @return mixed
     */
    public function check()
    {
        $ids = $this->request->param('id', '');
        $ids = explode(',', $ids);

        $where = ['industry.is_del' => 0,'industry.id' => ['neq',19], 'industry.parent_id' => ['neq',0]];
        $lists = db('industry_cate')
            ->alias('industry')
            ->join('__INDUSTRY_CATE__ parent','industry.parent_id = parent.id')
            ->field('industry.*,parent.name as pname')
            ->where($where)->select();

        $view = get_view();
        $view->assign('header',[
            'token' => $this->token,
            'device' => $this->deviceType
        ]);
        $view->assign('lists', $lists);
        $view->assign('ids', $ids);
        echo $view->fetch();
        die;
    }
}